package com.easthome;

import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.ResourceBundle;

public class RedisConnectionPool {
    static JedisPool jedisPool=null;
    static{
        ResourceBundle jedispool = ResourceBundle.getBundle("jedispool");
        Integer maxTotal= Integer.parseInt(jedispool.getString("jedis.maxTotal"));
        Integer maxIdle= Integer.parseInt(jedispool.getString("jedis.maxIdle"));
        Integer minIdle= Integer.parseInt(jedispool.getString("jedis.minIdle"));
        String host= jedispool.getString("jedis.host");
        Integer port= Integer.parseInt(jedispool.getString("jedis.port"));
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(maxTotal);
        jedisPoolConfig.setMinIdle(minIdle);
        jedisPoolConfig.setMaxIdle(maxIdle);
        jedisPool = new JedisPool(jedisPoolConfig, host, port);
    }
    public static Jedis getJedis(){

        return jedisPool.getResource();
    }


}